package com.qd.common.sys.domain.entity.article;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

/**
 * 附件
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class ArticleFileDTO extends BaseQuery {

    @ExcelIgnore
    @JsonIgnore
    private static final String EXCEL_TITLE = "附件";
    /**
     * 主键
     */
    @ExcelProperty(value = {EXCEL_TITLE, "标识"})
    @Size(max = 50, message = "标识长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String docId;
    /**
     * 名称
     */
    @ExcelProperty(value = {EXCEL_TITLE, "名称"})
    @Size(max = 80, message = "名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String docName;
    /**
     * 路径
     */
    @ExcelProperty(value = {EXCEL_TITLE, "路径"})
    @Size(max = 255, message = "路径长度不能超过{max}位", groups = DefaultGroup.class)
    private String docPath;
    /**
     * 完整路径
     */
    private String docPathDisplay;
    /**
     * 大小
     */
    @ExcelProperty(value = {EXCEL_TITLE, "大小"})
    private Long docSize;
    /**
     * 大小，转换成KB,MB,GB,TB
     */
    private String docSizeDisplay;
    /**
     * 序号
     */
    @ExcelProperty(value = {EXCEL_TITLE, "序号"})
    private Integer idx;
    /**
     * 文件类型
     */
    @NotBlank(message = "文件类型不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "文件类型长度不能超过{max}位", groups = DefaultGroup.class)
    private String attachmentType;
    /**
     * 文件类型显示
     */
    private String attachmentTypeDisplay;
    /**
     * 文章标识
     */
    @ExcelProperty(value = {EXCEL_TITLE, "文章标识"})
    @NotBlank(message = "文章标识不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "文章标识长度不能超过{max}位", groups = DefaultGroup.class)
    private String articleId;

    @Override
    public void freeData() {
        this.docId = null;
        this.docName = null;
        this.docPath = null;
        this.docPathDisplay = null;
        this.docSize = null;
        this.docSizeDisplay = null;
        this.idx = null;
        this.articleId = null;
        this.attachmentType = null;
        this.attachmentTypeDisplay = null;
        super.freeData();
    }
}
